﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// “用户控件”项模板在 http://go.microsoft.com/fwlink/?LinkId=234236 上提供

namespace WeixinSB.Control
{
    public sealed partial class IphoneControl : UserControl
    {

        public string ChinaMoblie
        {
            get { return (string)GetValue(ChinaMoblieProperty); }
            set { SetValue(ChinaMoblieProperty, value); }
        }

        // Using a DependencyProperty as the backing store for ChinaMoblie.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty ChinaMoblieProperty =
            DependencyProperty.Register("ChinaMoblie", typeof(string), typeof(IphoneControl), new PropertyMetadata(null, new PropertyChangedCallback(PropertyChanged)));



        public IphoneControl()
        {
            this.InitializeComponent();
            this.Loaded += IphoneControl_Loaded;
        }

        static void PropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ((IphoneControl)d).cm.Text = e.NewValue.ToString(); 
        }

        void IphoneControl_Loaded(object sender, RoutedEventArgs e)
        {

            //cm.Text = ChinaMoblie;

            //if (DateTime.Now.Hour > 12)
            {
                time.Text = DateTime.Now.ToString("HH:mm");
            }
            //else
            {
                // time.Text = "上午" + DateTime.Now.ToString("hh:mm");
            }

            var rd = new Random();

            per.Text = rd.Next(23, 35) + "%";
        }

    }
}
